package create.com.modelproaction;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import create.com.modelproaction.adapter.StaggeredRecyclerAdapter;
import create.com.modelproaction.entity.Homemenubean;

//https://blog.csdn.net/ww897532167/article/details/85952498/  必看

public class MainActivity extends Activity implements View.OnClickListener {

    private RecyclerView thired_recyclerview;
    private List<Homemenubean> homeNumList = new ArrayList<>();
    private StaggeredRecyclerAdapter staggeredRecyclerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        // 创建一个垂直方向的瀑布流布局管理器（每行3列）


//————————————————
//        版权声明：本文为CSDN博主「showswoller」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//        原文链接：https://blog.csdn.net/jiebaoshayebuhui/article/details/127838031
        LoadData();
    }

    private void LoadData() {
//        StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.)
        StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(
                2, RecyclerView.VERTICAL);
        manager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
        thired_recyclerview.setLayoutManager(manager); // 设置循环视图的布局管理器
        for (int i = 0; i < 200; i++) {
            Homemenubean hb = new Homemenubean();
            hb.setHomeMeName("zhangsan");
            hb.setHomeMeImage(R.drawable.hehuoren);
            homeNumList.add(hb);
        }
        int space = 20;
        thired_recyclerview.setLayoutManager(manager);
        thired_recyclerview.setItemAnimator(null);
//        thired_recyclerview.addItemDecoration(new StaggeredItemDecoration(space));//单位px
        staggeredRecyclerAdapter = new StaggeredRecyclerAdapter(homeNumList);
//        mAdapter.setCards(mCards);
        thired_recyclerview.setAdapter(staggeredRecyclerAdapter);
//————————————————
//        版权声明：本文为CSDN博主「程序员徐师兄」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//        原文链接：https://blog.csdn.net/JasonXu94/article/details/129452478

        staggeredRecyclerAdapter.setOnItemClickListener(new StaggeredRecyclerAdapter.OnItemClickListener() {
            @Override
            public void onClick(int position) {
                Intent intent = new Intent();

            }
        });
    }

    private void initView() {
        thired_recyclerview = findViewById(R.id.thired_recyclerview);
//        thired_recyclerview.setLayoutManager();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {


        }
    }
}
